﻿using common.libs;
using common.server;
using common.server.model;
using System.Threading.Tasks;

namespace client.service.tcpforward
{
    public class TcpForwardMessengerSender
    {
        private readonly MessengerSender messengerSender;
        public TcpForwardMessengerSender(MessengerSender messengerSender)
        {
            this.messengerSender = messengerSender;
        }

        public SimpleSubPushHandler<OnDataArg> OnData { get; } = new SimpleSubPushHandler<OnDataArg>();
        public async Task Send(SendArg arg)
        {
            await messengerSender.SendOnly(new MessageRequestParamsInfo<TcpForwardInfo>
            {
                Path = "TcpForward/Execute",
                Connection = arg.Connection,
                Data = arg.Data
            }).ConfigureAwait(false);
        }
    }
    public class SendArg
    {
        public IConnection Connection { get; set; }
        public TcpForwardInfo Data { get; set; }
    }
    public class OnDataArg : SendArg { }
}
